IAxis.DigitalCamSwitch method
Uses an axis' position to control a switch that triggers a digital output. When an axis reaches a certain position, a switch is turned on or off. A switch can be controlled by a forward and backward movement of an axis.
Namespace: IntervalZero.KINGSTAR.Base.Class
Assembly: IntervalZero.KINGSTAR.Base.Class (in IntervalZero.KINGSTAR.Base.dll) Version: 4.4.0.0
Syntax
void DigitalCamSwitch(
IList<McCamSwitch> switches,
IList<McOutput> outputs,
IList<McTrack> tracks,
uint enableMask,
McSource valueSource
)
Sub DigitalCamSwitch(
switches As IList(Of McCamSwitch),
outputs As IList(Of McOutput),
tracks As IList(Of McTrack),
enableMask As UInteger,
valueSource As McSource
)
Parameters
switches
Type: IList<McCamSwitch>
Controls the switching actions. The track numbers need to be in order.
outputs
Selects which digital output will be controlled by the corresponding track.
tracks
Adds the compensation time and hysteresis to the switches on a track. TrackNumber is defined in Switches.
enableMask
Type: uint
Enables the different tracks. This parameter is 32 bits of BOOL. The corresponding track in the track array is enabled when its BOOL value is set to one.
valueSource
Type: McSource
Defines the source for axis values. For example, positions:
- mcCommandedValue, mcSetValue – synchronization on set value. We suggest you use these settings.
- mcActualValue – synchronization on actual value. This setting may not be stable.
Remarks
- McCamSwitch is a vendor-specific structure that defines switches for digital cam.
- McOutput is a vendor-specific structure linked to the (physical) outputs. If you are using your servo drive's digital output (DO), you need to use the ISubsystem.AxisOutput property before the ISubsystem.Start method.
- McTrack is vendor-specific structure containing the track properties. For example, the compensation time per track (A track is a set of switches related to one output). It can also contain the reference to the output.
- This functionality is sometimes called PLS – Phase or Position or Programmable Limit Switch.
Elements within McCamSwitch Class
B/E | Parameter | Type | Description |
---|---|---|---|
B | TrackNumber | INT | The index of the track. Indexes are zero-based. |
B | FirstOnPosition [user unit] | LREAL | The position from which the switch is on. |
B | LastOnPosition [user unit] | LREAL | The position from which the switch is off. |
E | AxisDirection | INT |
The direction of the axis. The default value is zero. If you select one or two, the switch is active only when the axis is moving in the specified direction. Both: 0, Positive: 1, Negative: 2. |
E | CamSwitchMode | INT |
The cam switch is controlled by axis' positions or time. The default value is zero. If choosing Position, you need to set FirstOnPosition and LastOnPosition; if choosing Time, you need to set FirstOnPosition and Duration. Position: 0, Time: 1. |
E | Duration | TIME | How long the switch is on. This property is available when CamSwitchMode is Time. The unit is second. |
Elements within McTrack Class
B/E | Parameter | Type | Description |
---|---|---|---|
E | OnCompensation | TIME | Compensation time with which the switch is turned on (rising edge) before or after the switching point per track. If the value is positive, the switch-on will be delayed; if the value is negative, the switch-on will be advanced. |
E | OffCompensation | TIME | Compensation time with which the switch is turned off (falling edge) before or after the switching point per track. If the value is positive, the switch-off will be delayed; if the value is negative, the switch-off will be advanced. |
E | Hysteresis [unit] | LREAL | Distance from the switching point (in positive and negative direction) in which the switch is not turned on or off until the axis has left this area. This can avoid multiple switching around the switching point. |
This definition of a cam has a start and an end position, so the user can define each single cam, which has a FirstOnPosition and a LastOnPosition (or time). This function is similar to a mechanical cam but has the additional advantages that the outputs can be set for a certain time, and to give it a time-compensation and a hysteresis.
CamSwitchMode: It can be position or time.
Duration: Time, the output of a time cam is ON. The time compensation (OnCompensation and OffCompensation) can be positive or negative. Negative means the output changes before the switching position is reached.
Hysteresis: This parameter avoids the phenomenon where the output continually switches if the axis is near the switching point and the actual position is jittering around the switching position. Hysteresis is part of McTrack, which means that a different hysteresis is possible for each track.
Example of McCamSwitch
Parameter | Type | Switch01 | Switch02 | Switch03 | Switch04 | ... | SwitchN |
---|---|---|---|---|---|---|---|
TrackNumber | INTEGER | 1 | 1 | 1 | 2 | ||
FirstOnPosition [unit] | LREAL | 2000 | 2500 | 4000 | 3000 | ||
LastOnPosition [unit] | LREAL | 3000 | 3000 | 6000 | -- | ||
AxisDirection | INTEGER | 1=Pos | 2=Neg | 0=Both | 0=Both | ||
CamSwitchMode | INTEGER | 0=Position | 0=Position | 0=Position | 1=Time | ||
Duration | LREAL | -- | -- | -- | 1.35 seconds |
Example of McOutput
Parameter | MC_OUTPUT[0] | MC_OUTPUT[1] | MC_OUTPUT[2] | - | - | - | MC_OUTPUT[31] |
---|---|---|---|---|---|---|---|
IsAxis | FALSE | FALSE | FALSE | - | - | - | FALSE |
Index | 0 | 0 | 0 | - | - | - | 0 |
BitOffset | 0 | 1 | 2 | - | - | - | 31 |
Example of an I/O module
The figure below uses the values from the example of McCamSwitch above. It uses neither On/OffCompensation nor Hysteresis. This is the behavior of the outputs, when the axis is moving continuously in the positive direction.
DigitalCamSwitch – Positive Direction
Positive Direction: Behavior of the Outputs
TrackNumber 1 (Switch01, 02, 03) is mapped to McOutput[1] and TrackNumber 2 (Switch04) is mapped to McOutput[2]. When Switch01, Switch02, and Switch03 are triggered, the second output (Output 1) on the first I/O module (Index 0) is turned on. When Switch04 is triggered, the third output is turned on (Output 2).
Example of On/Off Compensation
This example uses OnCompensation -125ms and OffCompensation +250ms.
The figure below shows the behavior of the outputs, when the axis is moving continuously in the negative direction without On/OffCompensation and without Hysteresis.
DigitalCamSwitch – Negative Direction
Negative Direction: Behavior of the Outputs
EnableMask
EnableMask is an uint parameter that contains 32 bits. Each bit is a BOOL value that controls an output. An output is enabled or disabled by setting its corresponding bit TRUE or FALSE. For example, bit 0 controls McOutput[0] and bit 1 controls McOutput[1]. If bit 0 and 1 are TRUE, their outputs are enabled, which means their outputs will be turned on when their corresponding switches are triggered; if they are FALSE, their outputs are disabled, which means their outputs won't be turned on even if their corresponding switches are triggered.
Bits | Bit 0 | Bit 1 | Bit 2 | Bit 3 | - | - | - | - | Bit 31 |
---|---|---|---|---|---|---|---|---|---|
Value | TRUE/FALSE | TRUE/FALSE | TRUE/FALSE | TRUE/FALSE | - | - | - | - | TRUE/FALSE |
Example of McOutput
Parameter | MC_OUTPUT[0] | MC_OUTPUT[1] | MC_OUTPUT[2] | - | - | - | MC_OUTPUT[31] |
---|---|---|---|---|---|---|---|
IsAxis | FALSE | FALSE | FALSE | - | - | - | FALSE |
Index | 0 | 0 | 0 | - | - | - | 0 |
BitOffset | 0 | 1 | 2 | - | - | - | 31 |
Example 1 of EnableMask Bits
Bit 0, 1, and 2 are TRUE, which means Output 0, 1, and 2 are enabled. The outputs are turned on when their corresponding switches are triggered.
Bits | Bit 0 | Bit 1 | Bit 2 | Bit 3 | - | - | - | - | Bit 31 |
---|---|---|---|---|---|---|---|---|---|
Value | TRUE | TRUE | TRUE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE |
Positive Direction: Behavior of the Outputs
Example 2 of EnableMask Bits
Bit 0 and 2 are TRUE, which means Output 0 and 2 are enabled. Only these two outputs are turned on when their corresponding switches are triggered.
Bits | Bit 0 | Bit 1 | Bit 2 | Bit 3 | - | - | - | - | Bit 31 |
---|---|---|---|---|---|---|---|---|---|
Value | TRUE | FALSE | TRUE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE |
Positive Direction: Behavior of the Outputs
Example 3 of EnableMask Bits
All bits are FALSE, which means all outputs are disabled. No outputs are turned on even if their corresponding switches are triggered.
Bits | Bit 0 | Bit 1 | Bit 2 | Bit 3 | - | - | - | - | Bit 31 |
---|---|---|---|---|---|---|---|---|---|
Value | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE | FALSE |
Positive Direction: Behavior of the Outputs
See also